<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>reduce</title>
</head>
<body>
<script type="text/javascript">
    var b = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16];
    var sum = b.slice(0,10).reduce(function (pre,cur) {
        return pre + cur;
    });
    console.log(sum)
</script>
</body>
</html>